package com.itheima.health.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.health.pojo.Order;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

public interface OrderMapper extends BaseMapper<Order> {
    @Select("select count(1) from t_order where MEMBER_ID = #{mid} and SETMEAL_ID=#{sid} and ORDERDATE = #{orderdate}")
    int findOrderByMemberIDAndSetmealIDAndOrderDate(@Param("mid") Integer mid, @Param("sid") int sid, @Param("orderdate") String orderdate);

    @Select("SELECT tm.name as member,tsm.name as setmeal,tor.orderdate as orderDate,tor.ORDERTYPE as orderType " +
            "FROM  t_order tor , t_setmeal tsm , t_member tm " +
            "WHERE tor.MEMBER_ID = tm.id  and  tor.SETMEAL_ID = tsm.id " +
            "and  tor.id = #{id}")
    Map findOrderInfoById(@Param("id") int id);
}
